/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Bean;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Reynusa
 */
public class TerimaSupplier {

    private String kodebarang;
    private Integer jumlah;
    private Integer harsatuan;
    private Integer hartot;
    private String tgl_terimasupp;

    public TerimaSupplier() {
    }

    public Integer getHarsatuan() {
        return harsatuan;
    }

    public void setHarsatuan(Integer harsatuan) {
        this.harsatuan = harsatuan;
    }

    public Integer getHartot() {
        return hartot;
    }

    public void setHartot(Integer hartot) {
        this.hartot = hartot;
    }

    public Integer getJumlah() {
        return jumlah;
    }

    public void setJumlah(Integer jumlah) {
        this.jumlah = jumlah;
    }

    public String getKodebarang() {
        return kodebarang;
    }

    public void setKodebarang(String kodebarang) {
        this.kodebarang = kodebarang;
    }

    public String getTgl_terimasupp() {
        return tgl_terimasupp;
    }

    public void setTgl_terimasupp(String tgl_terimasupp) {
        this.tgl_terimasupp = tgl_terimasupp;
    }

    public List lihatterima(String tgl_terimasupp) throws SQLException {
        List sterima = new ArrayList();
//        Connection conn = DataBaseConnection.open("jdbc:oracle:thin:@localhost:1521:xe", "hr", "12345");
        Connection conn = DataBaseConnection.open("jdbc:oracle:thin:@172.23.9.185:1521:orcl", "mhs115314009", "mhs115314009");
        String retrieveQuery = "select * from TRANSAKSITERIMASUPP where tglterima='" + tgl_terimasupp + "'";
        Statement st = conn.createStatement();
        ResultSet rs = st.executeQuery(retrieveQuery);
        while (rs.next()) {
            TerimaSupplier terimax = new TerimaSupplier();
            terimax.setKodebarang(rs.getString("kodebarang"));
            terimax.setJumlah(Integer.parseInt(rs.getString("jumlah")));
            terimax.setHarsatuan(Integer.parseInt(rs.getString("harga")));
            terimax.setTgl_terimasupp(rs.getString("tglterima"));
            sterima.add(terimax);
        }
        conn.commit();
        return sterima;
    }
}
